package dcedit.factories;

// Import Java SDK Classes
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import javax.swing.tree.*;

// Import Application Classes
import dcedit.DCEdit;
import dcedit.util.*;

/** DialogFactory class */
public class DialogFactory {
   /** Private Constructor */
   private DialogFactory() {} // constructor

   /** createTranslateTemplateDialog method */
   public static JDialog createTranslateTemplateDialog(final String TEMPLATE_TEXT,final boolean NEW_TAB) {
      // Declare components
      final JDialog DIALOG = new JDialog();
      final JPanel TEMPLATE_PARAM_CONTAINER_PANEL = new JPanel();
      final JPanel TEMPLATE_PARAM_PANEL = new JPanel(new GridLayout(2, 2));
      final JLabel BEGIN_TEMPLATE_EXPRESSION_LABEL = new JLabel("Begin Template expression");
      final JLabel END_TEMPLATE_EXPRESSION_LABEL = new JLabel("End Template Expression");
      final JPanel BEGIN_TEMPLATE_EXPRESSION_LABEL_PANEL = new JPanel();
      final JPanel END_TEMPLATE_EXPRESSION_LABEL_PANEL = new JPanel();
      final JPanel BEGIN_TEMPLATE_EXPRESSION_FIELD_PANEL = new JPanel();
      final JPanel END_TEMPLATE_EXPRESSION_FIELD_PANEL = new JPanel();
      final JPanel TRANSLATE_PANEL = new JPanel();
      final JPanel CANCEL_PANEL = new JPanel();

      // Set dialog title, layout, and styles.
      DIALOG.setTitle(Constants.TRANSLATE_TEMPLATE_DIALOG_TITLE);
      DIALOG.getContentPane().setLayout(new BoxLayout(DIALOG.getContentPane(), BoxLayout.Y_AXIS));

      // Add vertical spacing.
      DIALOG.getContentPane().add(Box.createVerticalStrut(Constants.PANEL_PAD));

      // Add labels to the label panels.
      BEGIN_TEMPLATE_EXPRESSION_LABEL_PANEL.add(BEGIN_TEMPLATE_EXPRESSION_LABEL);
      END_TEMPLATE_EXPRESSION_LABEL_PANEL.add(END_TEMPLATE_EXPRESSION_LABEL);

      Constants.BEGIN_TEMPLATE_EXPRESSION_FIELD.addKeyListener(ActionFactory.createReloadTemplateTokensActionListener());
      Constants.END_TEMPLATE_EXPRESSION_FIELD.addKeyListener(ActionFactory.createReloadTemplateTokensActionListener());

      // Add fields to field panels.
      BEGIN_TEMPLATE_EXPRESSION_FIELD_PANEL.add(Constants.BEGIN_TEMPLATE_EXPRESSION_FIELD);
      END_TEMPLATE_EXPRESSION_FIELD_PANEL.add(Constants.END_TEMPLATE_EXPRESSION_FIELD);

      // Add label and field panels to the template param panel.
      TEMPLATE_PARAM_PANEL.add(BEGIN_TEMPLATE_EXPRESSION_LABEL_PANEL);
      TEMPLATE_PARAM_PANEL.add(BEGIN_TEMPLATE_EXPRESSION_FIELD_PANEL);
      TEMPLATE_PARAM_PANEL.add(END_TEMPLATE_EXPRESSION_LABEL_PANEL);
      TEMPLATE_PARAM_PANEL.add(END_TEMPLATE_EXPRESSION_FIELD_PANEL);

      // Add the template param panel to the template param container panel, this is to preserve spacing.
      TEMPLATE_PARAM_CONTAINER_PANEL.add(TEMPLATE_PARAM_PANEL);

      // Add the template param container panel to the dialog.
      DIALOG.getContentPane().add(TEMPLATE_PARAM_CONTAINER_PANEL);

      // Add a separator to the dialog.
      DIALOG.getContentPane().add(new JSeparator(JSeparator.HORIZONTAL));

      // Clear current model data.
      Constants.TEMPLATE_TOKEN_TABLE_MODEL.setRowCount(0);
      Constants.TEMPLATE_TOKEN_TABLE_MODEL.setColumnCount(0);

      // Set model columns.
      Constants.TEMPLATE_TOKEN_TABLE_MODEL.addColumn("Token");
      Constants.TEMPLATE_TOKEN_TABLE_MODEL.addColumn("Translation");

      // Update current model data.
      Util.updateTemplateTokenTableModel(TEMPLATE_TEXT);

      // Add the template token table to a scroll pane.
      final JScrollPane TEMPLATE_TOKEN_SCROLL_PANE = new JScrollPane(Constants.TEMPLATE_TOKEN_TABLE);

      // Set scroll pane size, for readability and usability.
      TEMPLATE_TOKEN_SCROLL_PANE.setPreferredSize(new Dimension(350, 250));

      // Add the scroll pane to the dialog.
      DIALOG.getContentPane().add(TEMPLATE_TOKEN_SCROLL_PANE);

      // Add a separator to the dialog.
      DIALOG.getContentPane().add(new JSeparator(JSeparator.HORIZONTAL));

      // Add the translate button to the roll panel.
      TRANSLATE_PANEL.add(BtnFactory.createTranslateDialogBtn(DIALOG,TEMPLATE_TEXT,NEW_TAB));

      // Add the close button to the close panel.
      CANCEL_PANEL.add(BtnFactory.createCancelTranslateDialogBtn(DIALOG));

      // Add the close panel to the dialog.
      DIALOG.getContentPane().add(TRANSLATE_PANEL);

      // Add the close panel to the dialog.
      DIALOG.getContentPane().add(CANCEL_PANEL);

      // Add vertical spacing.
      DIALOG.getContentPane().add(Box.createVerticalStrut(Constants.PANEL_PAD));

      // Pack contents and center on screen.
      DIALOG.pack();
      DIALOG.setLocationRelativeTo(null);
      DIALOG.setAlwaysOnTop(true);

      // Finally, return the dialog.
      return DIALOG;
   } // END createTranslateTemplateDialog

   /** createDiceDialog method */
   public static JDialog createDiceDialog() {
      // Declare components
      final JDialog DIALOG = new JDialog();
      final GridBagConstraints GRID_CONST = new GridBagConstraints();

      // Set dialog title and layout
      DIALOG.setTitle(Constants.DICE_DIALOG_TITLE);
      DIALOG.getContentPane().setLayout(new GridBagLayout());

      // Initialize the layout constants
      GRID_CONST.fill = GridBagConstraints.HORIZONTAL;
      GRID_CONST.insets = new Insets(3,3,3,3); // top,left,bottom,right
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      GRID_CONST.gridy = 0;

      // Add the die quantity label to the dialog
      GRID_CONST.gridx = 0;
      DIALOG.getContentPane().add(new JLabel("QTY"), GRID_CONST);

      // Add the die text label to the dialog
      GRID_CONST.gridx = 1;
      DIALOG.getContentPane().add(new JLabel("DIE"), GRID_CONST);

      // Add the a blank to the dialog
      GRID_CONST.gridx = 2;
      DIALOG.getContentPane().add(new JLabel(" "), GRID_CONST);

      // For each die in dice array.
      for(final IntegerSpinner QTY_SPINNER : Constants.DICE_SPINNERS) {
         final String DIE_PATH_PREFIX = QTY_SPINNER.getLabel().getText().toLowerCase();
         final String DIE_PATH_SUFFIX = "-32.png";
         final String DIE_FULL_PATH = Constants.DICE_IMAGE_PATH + DIE_PATH_PREFIX + DIE_PATH_SUFFIX;

         // Set the size of the spinner.
         Util.setComponentSizes(QTY_SPINNER, new Dimension(50, 20), true, true);

         QTY_SPINNER.setBorder(BorderFactory.createLineBorder(Color.BLACK));

         // Increment the grid Y index
         GRID_CONST.gridy += 1;

         // Add the die quantity spinner to the dialog
         GRID_CONST.gridx = 0;
         DIALOG.getContentPane().add(QTY_SPINNER, GRID_CONST);

         // Add the die text to the dialog
         GRID_CONST.gridx = 1;
         DIALOG.getContentPane().add(QTY_SPINNER.getLabel(), GRID_CONST);

         // Add the die image to the dialog
         GRID_CONST.gridx = 2;
         DIALOG.getContentPane().add(new OmniImage(DCEdit.class.getResource(DIE_FULL_PATH)), GRID_CONST);
      } // END loop

      // Update the layout constants for the dialog options
      GRID_CONST.gridwidth = 3;
      GRID_CONST.gridx = 0;

      // Add the gen dice stats checkbox and label to the dialog
      GRID_CONST.gridy += 1;
      DIALOG.getContentPane().add(Constants.GEN_DICE_STATS_CHECK_BOX, GRID_CONST);

      // Add the roll button to the dialog.
      GRID_CONST.gridy += 1;
      DIALOG.getContentPane().add(BtnFactory.createRollDiceBtn(), GRID_CONST);

      // Add the reset button to the dialog.
      GRID_CONST.gridy += 1;
      DIALOG.getContentPane().add(BtnFactory.createResetDiceBtn(), GRID_CONST);

      // Add the close button to the dialog.
      GRID_CONST.gridy += 1;
      DIALOG.getContentPane().add(BtnFactory.createCloseDiceDialogBtn(DIALOG), GRID_CONST);

      // Pack contents and center on screen.
      DIALOG.pack();
      DIALOG.setLocationRelativeTo(null);
      DIALOG.setAlwaysOnTop(true);

      // Finally, return the dialog.
      return DIALOG;
   } // END createDiceDialog

   /** createDiceModDialog method */
   public static JDialog createDiceModDialog() {
      // Declare components
      final JDialog DIALOG = new JDialog();
      final GridBagConstraints GRID_CONST = new GridBagConstraints();
      final JPanel ROLL_PANEL = new JPanel();
      final JPanel RESET_PANEL = new JPanel();
      final JPanel CLOSE_PANEL = new JPanel();
      final Dimension SPINNER_DIM = new Dimension(50, 20); // Dimensions for spinners

      // Set dialog title, layout, and styles.
      DIALOG.setTitle(Constants.DICE_MOD_DIALOG_TITLE);
      DIALOG.getContentPane().setLayout(new GridBagLayout());
      GRID_CONST.fill = GridBagConstraints.HORIZONTAL;
      GRID_CONST.insets = new Insets(3,3,3,3); // top,left,bottom,right

      // Set the size of num dice spinner.
      Util.setComponentSizes(Constants.DICE_QTY_SPINNER, SPINNER_DIM, true, true);

      // Add the num dice spinner to the dialog.
      Constants.DICE_QTY_SPINNER.addChangeListener(ActionFactory.createDiceModSpinnerChangeListener());
      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 0;
      DIALOG.getContentPane().add(Constants.DICE_QTY_SPINNER, GRID_CONST);

      // Add the dice label to the dialog.
      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 0;
      GRID_CONST.insets = new Insets(3,10,3,3); // top,left,bottom,right
      DIALOG.getContentPane().add(new JLabel("D"), GRID_CONST);
      GRID_CONST.insets = new Insets(3,3,3,3); // top,left,bottom,right

      // Set the size of num sides spinner.
      Util.setComponentSizes(Constants.DICE_NUM_SIDES_SPINNER, SPINNER_DIM, true, true);

      // Add the num sides spinner to the dialog.
      Constants.DICE_NUM_SIDES_SPINNER.setModel(new SpinnerNumberModel(2, 2, 100, 1));
      Constants.DICE_NUM_SIDES_SPINNER.addChangeListener(ActionFactory.createDiceModSpinnerChangeListener());
      GRID_CONST.gridx = 2;
      GRID_CONST.gridy = 0;
      DIALOG.getContentPane().add(Constants.DICE_NUM_SIDES_SPINNER, GRID_CONST);

      // Add the mod option combo box to the dialog.
      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 1;
      GRID_CONST.gridwidth = 2;
      DIALOG.getContentPane().add(ComboBoxFactory.createDiceModOptionsList(), GRID_CONST);

      // Set the size of mod num spinner.
      Util.setComponentSizes(Constants.DICE_MOD_SPINNER, SPINNER_DIM, true, true);

      // Add the mod num spinner to the dialog.
      Constants.DICE_MOD_SPINNER.addChangeListener(ActionFactory.createDiceModSpinnerChangeListener());
      Constants.DICE_MOD_SPINNER.setEnabled(false);
      GRID_CONST.gridx = 2;
      GRID_CONST.gridy = 1;
      DIALOG.getContentPane().add(Constants.DICE_MOD_SPINNER, GRID_CONST);

      // Add the roll button to the roll panel.
      ROLL_PANEL.add(BtnFactory.createRollDiceModBtn());

      // Add the roll panel to the dialog.
      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 2;
      GRID_CONST.gridwidth = 3;
      GRID_CONST.insets = new Insets(1,3,1,3); // top,left,bottom,right
      DIALOG.getContentPane().add(ROLL_PANEL, GRID_CONST);

      // Add the reset button to the reset panel.
      RESET_PANEL.add(BtnFactory.createResetDiceModBtn());

      // Add the reset panel to the dialog.
      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 3;
      GRID_CONST.gridwidth = 3;
      GRID_CONST.insets = new Insets(1,3,1,3); // top,left,bottom,right
      DIALOG.getContentPane().add(RESET_PANEL, GRID_CONST);

      // Add the close button to the close panel.
      CLOSE_PANEL.add(BtnFactory.createCloseDiceModDialogBtn(DIALOG));

      // Add the close panel to the dialog.
      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 4;
      GRID_CONST.gridwidth = 3;
      GRID_CONST.insets = new Insets(1,3,1,3); // top,left,bottom,right
      DIALOG.getContentPane().add(CLOSE_PANEL, GRID_CONST);

      // Pack contents and center on screen.
      DIALOG.pack();
      DIALOG.setLocationRelativeTo(null);
      DIALOG.setAlwaysOnTop(true);

      // Finally, return the dialog.
      return DIALOG;
   } // END createDiceModDialog

   /** createCharacterGenDialog method */
   public static JDialog createCharacterGenDialog() {
      // Declare components
      final JDialog DIALOG = new JDialog();
      final JPanel CHA_GEN_LEFTHAND_PANEL = new JPanel();
      final JPanel CHA_GEN_RIGHTHAND_PANEL = new JPanel();
      final JPanel CHA_NAME_LABEL_PANEL = new JPanel();
      final JLabel STAT_LABEL = new JLabel("Stats");
      final JPanel STAT_LABEL_PANEL = new JPanel();
      final JPanel STAT_PANEL = new JPanel();

      // Set the sprite spinner left-hand and right-hand spinner btn width.
      Constants.SPRITE_SPINNER.setSpinnerBtnWidth(27);

      // Set the sprite spinner tooltip text.
      Constants.SPRITE_SPINNER.setToolTipText(Constants.AVATAR_TOOLTIP_TEXT);

      // Set dialog title, layout, and styles.
      DIALOG.setTitle(Constants.CHARACTER_GEN_TITLE);
      DIALOG.getContentPane().setLayout(new FlowLayout());

      // Set panel layouts
      CHA_GEN_LEFTHAND_PANEL.setLayout(new BoxLayout(CHA_GEN_LEFTHAND_PANEL, BoxLayout.Y_AXIS));
      CHA_GEN_RIGHTHAND_PANEL.setLayout(new BoxLayout(CHA_GEN_RIGHTHAND_PANEL, BoxLayout.Y_AXIS));
      CHA_NAME_LABEL_PANEL.setLayout(new BoxLayout(CHA_NAME_LABEL_PANEL, BoxLayout.X_AXIS));
      STAT_LABEL_PANEL.setLayout(new BoxLayout(STAT_LABEL_PANEL, BoxLayout.X_AXIS));
      STAT_PANEL.setLayout(new GridLayout(Constants.CHARACTER_STAT_LIST.length, 2));

      // Add sprite spinner to the left-hand panel.
      CHA_GEN_LEFTHAND_PANEL.add(Constants.SPRITE_SPINNER);

      // Add vertical spacing.
      CHA_GEN_LEFTHAND_PANEL.add(Box.createVerticalStrut(Constants.PANEL_PAD * 5));

      // Add gender list to left-hand panel.
      CHA_GEN_LEFTHAND_PANEL.add(ComboBoxFactory.createCharacterGenderList());

      // Add race list to left-hand panel.
      CHA_GEN_LEFTHAND_PANEL.add(ComboBoxFactory.createCharacterRaceList());

      // Add class list to left-hand panel.
      CHA_GEN_LEFTHAND_PANEL.add(ComboBoxFactory.createCharacterClassList());

      // Add zodiac list to left-hand panel.
      CHA_GEN_LEFTHAND_PANEL.add(ComboBoxFactory.createCharacterZodiacList());

      // Add vertical spacing.
      CHA_GEN_LEFTHAND_PANEL.add(Box.createVerticalStrut(Constants.PANEL_PAD * 5));

      // Add character name label to the character name panel;
      // Add character name label panel to the left-hand panel.
      CHA_NAME_LABEL_PANEL.add(Constants.CHARACTER_NAME_FIELD.getLabel());
      CHA_NAME_LABEL_PANEL.add(Box.createHorizontalGlue());
      CHA_GEN_LEFTHAND_PANEL.add(CHA_NAME_LABEL_PANEL);

      // Add character name label
      Constants.CHARACTER_NAME_FIELD.setToolTipText(Constants.CHARACTER_NAME_TOOLTIP_TEXT);
      Constants.CHARACTER_NAME_FIELD.setTextLimit(10);
      CHA_GEN_LEFTHAND_PANEL.add(Constants.CHARACTER_NAME_FIELD);

      // Add vertical spacing.
      CHA_GEN_LEFTHAND_PANEL.add(Box.createVerticalStrut(Constants.PANEL_PAD * 12));

      // Add stat label to the stat label panel;
      // Add stat label panel to the right-hand panel.
      STAT_LABEL_PANEL.add(STAT_LABEL);
      CHA_GEN_RIGHTHAND_PANEL.add(STAT_LABEL_PANEL);

      // Add all stats
      for(final DCTextField CHA_STAT_FIELD : Constants.CHARACTER_STAT_LIST) {
         final JPanel CHA_STAT_LABEL_PANEL = new JPanel();
         final JPanel CHA_STAT_FIELD_PANEL = new JPanel();

         CHA_STAT_LABEL_PANEL.setLayout(new BoxLayout(CHA_STAT_LABEL_PANEL, BoxLayout.X_AXIS));

         CHA_STAT_FIELD.setEnabled(false);
         CHA_STAT_FIELD.setConentType(DCTextField.CONTENT_TYPE.NUMERIC_ONLY);

         CHA_STAT_LABEL_PANEL.add(CHA_STAT_FIELD.getLabel());
         CHA_STAT_LABEL_PANEL.add(Box.createHorizontalGlue());
         CHA_STAT_FIELD_PANEL.add(CHA_STAT_FIELD);

         STAT_PANEL.add(CHA_STAT_LABEL_PANEL);
         STAT_PANEL.add(CHA_STAT_FIELD_PANEL);
      } // END stat loop

      // Add stat panel to the right-hand panel.
      CHA_GEN_RIGHTHAND_PANEL.add(STAT_PANEL);

      // Add vertical spacing.
      CHA_GEN_RIGHTHAND_PANEL.add(Box.createVerticalStrut(Constants.PANEL_PAD * 3));

      // Add gen status btn.
      JPanel GEN_STATS_BTN_PANEL = new JPanel();
      GEN_STATS_BTN_PANEL.setLayout(new BoxLayout(GEN_STATS_BTN_PANEL, BoxLayout.X_AXIS));
      GEN_STATS_BTN_PANEL.add(BtnFactory.createGenStatsDialogBtn());
      CHA_GEN_RIGHTHAND_PANEL.add(GEN_STATS_BTN_PANEL);

      // Add vertical spacing.
      DIALOG.getContentPane().add(Box.createVerticalStrut(Constants.PANEL_PAD));

      // Add left-hand and right-hand panels to the dialog.
      DIALOG.getContentPane().add(CHA_GEN_LEFTHAND_PANEL);
      DIALOG.getContentPane().add(Box.createHorizontalStrut(Constants.PANEL_PAD * 5));
      DIALOG.getContentPane().add(CHA_GEN_RIGHTHAND_PANEL);

      // Add vertical spacing.
      DIALOG.getContentPane().add(Box.createVerticalStrut(Constants.PANEL_PAD));

      // Build Menu
      DIALOG.setJMenuBar(MenuFactory.createCharacterGenDialogMenuBar(DIALOG));

      // Pack contents and center on screen.
      DIALOG.pack();
      DIALOG.setLocationRelativeTo(null);
      DIALOG.setAlwaysOnTop(true);

      // Finally, return the dialog.
      return DIALOG;
   } // END createCharacterGenDialog

   /** createCharacterGenLoadDialog method */
   public static JDialog createCharacterGenLoadDialog() {
      // Declare components
      final JDialog DIALOG = new JDialog();
      final JLabel LIST_OF_CHARACTERS_LABEL = new JLabel("List of characters");
      final JPanel LIST_OF_CHARACTERS_LABEL_PANEL = new JPanel();
      final JPanel DC_CHARACTER_SELECTION_LIST_PANEL = new JPanel();
      final JPanel CANCEL_BTN_PANEL = new JPanel();

      // Set dialog title, layout, and styles.
      DIALOG.setTitle(Constants.CHARACTER_SELECTION_TITLE);
      DIALOG.getContentPane().setLayout(new BoxLayout(DIALOG.getContentPane(), BoxLayout.Y_AXIS));

      // Get list of
      final ArrayList<String> DC_CHARACTER_FILES =  Util.getListOfDCCharacters();
      final ArrayList<String> DC_CHARACTERS = new ArrayList<>();

      // Loop through character files and get only the character name
      for(final String FILE : DC_CHARACTER_FILES) {
         DC_CHARACTERS.add(FILE.replace(Constants.CHARACTER_PREFIX,"").replace(Constants.SER_SUFFIX,""));
      } // END loop

      // Create a list component to store the character selections
      final JList<String> DC_CHARACTER_SELECTION_LIST = new JList<>(DC_CHARACTERS.toArray(new String[DC_CHARACTERS.size()]));
      DC_CHARACTER_SELECTION_LIST.setVisibleRowCount(10);
      DC_CHARACTER_SELECTION_LIST.setFixedCellWidth(100);
      DC_CHARACTER_SELECTION_LIST.setBorder(BorderFactory.createLineBorder(Color.WHITE));
      DC_CHARACTER_SELECTION_LIST.addListSelectionListener(ActionFactory.createCharacterGenLoadSelectionListener(DIALOG, DC_CHARACTER_SELECTION_LIST));

      // Add label to label panel
      LIST_OF_CHARACTERS_LABEL_PANEL.add(LIST_OF_CHARACTERS_LABEL);

      // Add label panel to the dialog
      DIALOG.getContentPane().add(LIST_OF_CHARACTERS_LABEL_PANEL);

      // Add the selection list to the selection list panel
      DC_CHARACTER_SELECTION_LIST_PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD * 5));
      DC_CHARACTER_SELECTION_LIST_PANEL.add(DC_CHARACTER_SELECTION_LIST);
      DC_CHARACTER_SELECTION_LIST_PANEL.add(Box.createHorizontalStrut(Constants.PANEL_PAD * 5));

      // Add selection list panel to the dialog
      DIALOG.getContentPane().add(DC_CHARACTER_SELECTION_LIST_PANEL);

      // Add vertical spacing.
      DIALOG.getContentPane().add(Box.createVerticalStrut(Constants.PANEL_PAD));

      // Add the cancel btn to the cancel btn panel
      CANCEL_BTN_PANEL.add(BtnFactory.createCharacterGenLoadCancelBtn(DIALOG));

      // Add the cancel btn panel to the dialog
      DIALOG.getContentPane().add(CANCEL_BTN_PANEL);

      // Add vertical spacing.
      DIALOG.getContentPane().add(Box.createVerticalStrut(Constants.PANEL_PAD * 5));

      DIALOG.getSize().width = 300;
      DIALOG.getMinimumSize().width = 300;
      DIALOG.getPreferredSize().width = 300;

      // Pack contents and center on screen.
      DIALOG.pack();
      DIALOG.setLocationRelativeTo(null);
      DIALOG.setAlwaysOnTop(true);

      // Finally, return the dialog.
      return DIALOG;
   } // END createCharacterGenLoadDialog

   /** createCodecDialog method */
   public static JDialog createCodecDialog() {
      // Declare components
      final JDialog DIALOG = new JDialog();
      final JPanel LABEL_PANEL = new JPanel();
      final JPanel COMBO_BOX_PANEL = new JPanel();
      final JPanel ENCODE_DECODE_BTN_PANEL = new JPanel();
      final JPanel CLOSE_BTN_PANEL = new JPanel();
      final JScrollPane TEXT_AREA_PANE = new JScrollPane(Constants.CODEC_TEXT_AREA);
      final Dimension TEXT_AREA_DIM = new Dimension(140, 150);

      // Set dialog title, layout, and styles.
      DIALOG.setTitle(Constants.ENCODE_DECODE_DIALOG_TITLE);
      DIALOG.getContentPane().setLayout(new BoxLayout(DIALOG.getContentPane(), BoxLayout.Y_AXIS));

      // Set the text area size styles.
      Util.setComponentSizes(TEXT_AREA_PANE, TEXT_AREA_DIM, true, true);
      Constants.CODEC_TEXT_AREA.setFont(Constants.CODEC_TEXT_AREA.getFont().deriveFont(Font.BOLD));

      // Set the combo box items.
      Constants.CODEC_COMBO_BOX.removeAllItems();
      Constants.CODEC_COMBO_BOX.addItem("PlainText => Base64");
      Constants.CODEC_COMBO_BOX.addItem("Base64 => PlainText");
      Constants.CODEC_COMBO_BOX.addItem("PlainText => Base32");
      Constants.CODEC_COMBO_BOX.addItem("Base32 => PlainText");
      Constants.CODEC_COMBO_BOX.addItem("PlainText => MD5");
      Constants.CODEC_COMBO_BOX.addItem("PlainText => SHA");
      Constants.CODEC_COMBO_BOX.addItem("PlainText => Binary");
      Constants.CODEC_COMBO_BOX.addItem("Binary => PlainText");

      // Add components to panels.
      LABEL_PANEL.add(Constants.CODEC_LABEL);
      COMBO_BOX_PANEL.add(Constants.CODEC_COMBO_BOX);
      ENCODE_DECODE_BTN_PANEL.add(BtnFactory.createCodecEncodeDecodeBtn());
      CLOSE_BTN_PANEL.add(BtnFactory.createCodecCloseBtn(DIALOG));

      // Add panels to dialog.
      DIALOG.getContentPane().add(Box.createVerticalStrut(Constants.PANEL_PAD));
      DIALOG.getContentPane().add(LABEL_PANEL);
      DIALOG.getContentPane().add(TEXT_AREA_PANE);
      DIALOG.getContentPane().add(COMBO_BOX_PANEL);
      DIALOG.getContentPane().add(ENCODE_DECODE_BTN_PANEL);
      DIALOG.getContentPane().add(CLOSE_BTN_PANEL);
      DIALOG.getContentPane().add(Box.createVerticalStrut(Constants.PANEL_PAD));

      // Pack contents and center on screen.
      DIALOG.pack();
      DIALOG.setLocationRelativeTo(null);
      DIALOG.setAlwaysOnTop(true);

      // Finally, return the dialog.
      return DIALOG;
   } // END createCodecDialog

   /** createSearchDialog method */
   public static JDialog createSearchDialog() {
      // Declare components
      final JDialog DIALOG = new JDialog();
      final GridBagConstraints GRID_CONST = new GridBagConstraints();
      final Dimension TEXT_FIELD_DIM = new Dimension(175, 20); // Dimensions for text fields
      final JPanel FILE_LIST_PANEL = new JPanel();
      final JPanel SEARCH_PANEL = new JPanel();
      final JPanel CANCEL_PANEL = new JPanel();

      // Set dialog title, layout, and styles.
      DIALOG.setModal(false);
      DIALOG.setTitle(Constants.SEARCH_TEXT);
      DIALOG.getContentPane().setLayout(new GridBagLayout());
      GRID_CONST.fill = GridBagConstraints.HORIZONTAL;
      GRID_CONST.insets = new Insets(3,3,3,3); // top,left,bottom,right

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 0;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(new JLabel("Search Path"), GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 0;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      Util.setComponentSizes(Constants.SEARCH_PATH_FIELD, TEXT_FIELD_DIM, true, false);
      DIALOG.getContentPane().add(Constants.SEARCH_PATH_FIELD, GRID_CONST);

      GRID_CONST.gridx = 2;
      GRID_CONST.gridy = 0;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(BtnFactory.createSearchPathBrowseBtn(), GRID_CONST);

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 1;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(new JLabel("Search Term"), GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 1;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      Util.setComponentSizes(Constants.SEARCH_TERM_FIELD, TEXT_FIELD_DIM, true, false);
      DIALOG.getContentPane().add(Constants.SEARCH_TERM_FIELD, GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 2;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(Constants.RECURSIVE_SEARCH_CHECK_BOX, GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 3;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(Constants.CASE_SENSITIVE_CHECK_BOX, GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 4;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(Constants.REGULAR_EXPRESSION_CHECK_BOX, GRID_CONST);

      FILE_LIST_PANEL.setLayout(new VerticalLayout(1, VerticalLayout.CENTER, VerticalLayout.TOP));
      FILE_LIST_PANEL.setBorder(
         BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Colors.getAppFontColor()),
            "File List",
            TitledBorder.CENTER,
            TitledBorder.TOP
         )
      );

      JScrollPane fileListPane = new JScrollPane(Constants.SEARCH_FILE_LIST_FIELD);
      ButtonGroup radioGrp = new ButtonGroup();
      Constants.SEARCH_FILE_LIST_FIELD.setLineWrap(true);
      Constants.SEARCH_FILE_LIST_FIELD.setWrapStyleWord(true);
      radioGrp.add(Constants.SEARCH_FILE_LIST_EXCLUDE_BTN);
      radioGrp.add(Constants.SEARCH_FILE_LIST_INCLUDE_BTN);
      Util.setComponentSizes(fileListPane, 175, 75, true, true);
      Constants.SEARCH_FILE_LIST_FIELD.setFont(Constants.SEARCH_FILE_LIST_FIELD.getFont().deriveFont(Font.BOLD));
      FILE_LIST_PANEL.add(fileListPane);
      FILE_LIST_PANEL.add(Constants.SEARCH_FILE_LIST_EXCLUDE_BTN);
      FILE_LIST_PANEL.add(Constants.SEARCH_FILE_LIST_INCLUDE_BTN);
      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 5;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(FILE_LIST_PANEL, GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 6;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      Constants.SEARCH_PROGRESS_BAR.setValue(0); // Calibrate
      Constants.SEARCH_PROGRESS_BAR.setStringPainted(true); // Show percentage
      DIALOG.getContentPane().add(Constants.SEARCH_PROGRESS_BAR, GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 7;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      SEARCH_PANEL.add(BtnFactory.createSearchSearchBtn(DIALOG));
      DIALOG.getContentPane().add(SEARCH_PANEL, GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 8;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      CANCEL_PANEL.add(BtnFactory.createSearchCloseBtn(DIALOG));
      DIALOG.getContentPane().add(CANCEL_PANEL, GRID_CONST);

      // Pack contents and center on screen.
      DIALOG.pack();
      DIALOG.setLocationRelativeTo(null);
      DIALOG.setAlwaysOnTop(true);

      // Finally, return the dialog.
      return DIALOG;
   } // END createSearchDialog

   /** createJavaDocGenDialog method */
   public static JDialog createJavaDocGenDialog() {
      // Declare components
      final JDialog DIALOG = new JDialog();
      final GridBagConstraints GRID_CONST = new GridBagConstraints();
      final JPanel GEN_JAVADOC_PANEL = new JPanel();
      final JPanel CANCEL_PANEL = new JPanel();
      final Dimension TEXT_FIELD_DIM = new Dimension(175, 20); // Dimensions for text fields
      final Dimension STYLE_TREE_DIM = new Dimension(200, 400); // Dimensions for style tree
      final Dimension STYLE_TEXT_PANE_DIM = new Dimension(250, 400); // Dimensions for style text pane

      // Set dialog title, layout, and styles.
      DIALOG.setTitle(Constants.JAVA_DOC_GEN_TITLE);
      DIALOG.getContentPane().setLayout(new GridBagLayout());
      GRID_CONST.fill = GridBagConstraints.HORIZONTAL;
      GRID_CONST.insets = new Insets(3,3,3,3); // top,left,bottom,right

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 0;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(new JLabel("               Source Directory"), GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 0;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      Util.setComponentSizes(Constants.JAVADOC_SOURCE_FIELD, TEXT_FIELD_DIM, true, false);
      DIALOG.getContentPane().add(Constants.JAVADOC_SOURCE_FIELD, GRID_CONST);

      GRID_CONST.gridx = 2;
      GRID_CONST.gridy = 0;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(BtnFactory.createJavaDocSourceDirectoryBrowseBtn(), GRID_CONST);

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 1;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(new JLabel("               Distination Directory"), GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 1;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      Util.setComponentSizes(Constants.JAVADOC_DESTINATION_FIELD, TEXT_FIELD_DIM, true, false);
      DIALOG.getContentPane().add(Constants.JAVADOC_DESTINATION_FIELD, GRID_CONST);

      GRID_CONST.gridx = 2;
      GRID_CONST.gridy = 1;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(BtnFactory.createJavaDocDistinationDirectoryBrowseBtn(), GRID_CONST);

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 2;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(new JLabel("               Source Level"), GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 2;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(ComboBoxFactory.createSourceComplianceList(), GRID_CONST);

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 3;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(new JLabel("               Visibility Level"), GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 3;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      DIALOG.getContentPane().add(ComboBoxFactory.createVisibilityLevelList(), GRID_CONST);

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 4;
      GRID_CONST.gridwidth = 1;
      GRID_CONST.gridheight = 1;
      final DefaultMutableTreeNode ROOT_NODE = new DefaultMutableTreeNode("Styles");
      final JavaDocStyleRuleNode BODY_NODE = new JavaDocStyleRuleNode("body");
      BODY_NODE.addToStyleRuleDefinition("   font-family: 'Centaur', 'Trebuchet MS', 'sans-serif';");
      BODY_NODE.addToStyleRuleDefinition("   margin: 15px;");
      BODY_NODE.addToStyleRuleDefinition("   padding: 0px;");
      BODY_NODE.addToStyleRuleDefinition("   background-color: #000000;");
      BODY_NODE.addToStyleRuleDefinition("   color: #C0C0C0;");
      ROOT_NODE.add(BODY_NODE);
      final JavaDocStyleRuleNode BRACKET_NODE = new JavaDocStyleRuleNode(".bracket");
      BRACKET_NODE.addToStyleRuleDefinition("   font-family: 'Courier New', 'Courier', sans-serif;");
      BRACKET_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      ROOT_NODE.add(BRACKET_NODE);
      final DefaultMutableTreeNode DOJO_NODE = new DefaultMutableTreeNode("Dojo");
      final JavaDocStyleRuleNode DIJIT_CONTENT_PANE_NODE = new JavaDocStyleRuleNode(".dijitContentPane");;
      DIJIT_CONTENT_PANE_NODE.setStyleRulePrefix(".claro");
      DIJIT_CONTENT_PANE_NODE.addToStyleRuleDefinition("   font-family: 'Centaur', 'Trebuchet MS', 'sans-serif';");
      DIJIT_CONTENT_PANE_NODE.addToStyleRuleDefinition("   margin: 0px;");
      DIJIT_CONTENT_PANE_NODE.addToStyleRuleDefinition("   padding: 1px;");
      DIJIT_CONTENT_PANE_NODE.addToStyleRuleDefinition("   background-color: #000000;");
      DIJIT_CONTENT_PANE_NODE.addToStyleRuleDefinition("   color: #C0C0C0;");
      DOJO_NODE.add(DIJIT_CONTENT_PANE_NODE);
      final JavaDocStyleRuleNode DIJIT_TAB_PANE_NODE = new JavaDocStyleRuleNode(".dijitTabPane");;
      DIJIT_TAB_PANE_NODE.setStyleRulePrefix(".claro");
      DIJIT_TAB_PANE_NODE.addToStyleRuleDefinition("   font-family: 'Centaur', 'Trebuchet MS', 'sans-serif';");
      DIJIT_TAB_PANE_NODE.addToStyleRuleDefinition("   margin: 0px;");
      DIJIT_TAB_PANE_NODE.addToStyleRuleDefinition("   padding: 1px;");
      DIJIT_TAB_PANE_NODE.addToStyleRuleDefinition("   background-color: #000000;");
      DIJIT_TAB_PANE_NODE.addToStyleRuleDefinition("   color: #C0C0C0;");
      DOJO_NODE.add(DIJIT_TAB_PANE_NODE);
      final JavaDocStyleRuleNode DIJIT_TAB_NODE = new JavaDocStyleRuleNode(".dijitTab");
      DIJIT_TAB_NODE.setStyleRulePrefix(".claro");
      DIJIT_TAB_NODE.addToStyleRuleDefinition("   font-family: 'Centaur', 'Trebuchet MS', 'sans-serif';");
      DIJIT_TAB_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      DIJIT_TAB_NODE.addToStyleRuleDefinition("   background-color: #000000;");
      DIJIT_TAB_NODE.addToStyleRuleDefinition("   color: #C0C0C0;");
      DOJO_NODE.add(DIJIT_TAB_NODE);
      final JavaDocStyleRuleNode DIJIT_TAB_INNER_DIV_NODE = new JavaDocStyleRuleNode(".dijitTabInnerDiv");
      DIJIT_TAB_INNER_DIV_NODE.setStyleRulePrefix(".claro");
      DIJIT_TAB_INNER_DIV_NODE.addToStyleRuleDefinition("   font-family: 'Centaur', 'Trebuchet MS', 'sans-serif';");
      DIJIT_TAB_INNER_DIV_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      DIJIT_TAB_INNER_DIV_NODE.addToStyleRuleDefinition("   background-color: #000000;");
      DIJIT_TAB_INNER_DIV_NODE.addToStyleRuleDefinition("   color: #C0C0C0;");
      DOJO_NODE.add(DIJIT_TAB_INNER_DIV_NODE);
      final JavaDocStyleRuleNode DIJIT_TOOLTIP_CONTAINER = new JavaDocStyleRuleNode(".dijitTooltipContainer");
      DIJIT_TOOLTIP_CONTAINER.setStyleRulePrefix(".claro");
      DIJIT_TOOLTIP_CONTAINER.addToStyleRuleDefinition("   font-family: 'Centaur', 'Trebuchet MS', 'sans-serif';");
      DIJIT_TOOLTIP_CONTAINER.addToStyleRuleDefinition("   border: 1px solid #C0C0C0;");
      DIJIT_TOOLTIP_CONTAINER.addToStyleRuleDefinition("   font-weight: bold;");
      DIJIT_TOOLTIP_CONTAINER.addToStyleRuleDefinition("   background-color: #202020;");
      DIJIT_TOOLTIP_CONTAINER.addToStyleRuleDefinition("   color: #C0C0C0;");
      DOJO_NODE.add(DIJIT_TOOLTIP_CONTAINER);
      ROOT_NODE.add(DOJO_NODE);
      final DefaultMutableTreeNode CLASS_NODE = new DefaultMutableTreeNode("Class");
      final JavaDocStyleRuleNode CLASS_TABLE_NODE = new JavaDocStyleRuleNode(".classTable");
      CLASS_TABLE_NODE.addToStyleRuleDefinition("   padding: 0 0 50px 0;");
      CLASS_NODE.add(CLASS_TABLE_NODE);
      final JavaDocStyleRuleNode CLASS_ROW_NODE = new JavaDocStyleRuleNode(".classRow");
      CLASS_NODE.add(CLASS_ROW_NODE);
      final JavaDocStyleRuleNode CLASS_CELL_NODE = new JavaDocStyleRuleNode(".classCell");
      CLASS_CELL_NODE.addToStyleRuleDefinition("   background-color: #000066;");
      CLASS_CELL_NODE.addToStyleRuleDefinition("   color: #FFCC00;");
      CLASS_CELL_NODE.addToStyleRuleDefinition("   font-size: 28px;");
      CLASS_CELL_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      CLASS_CELL_NODE.addToStyleRuleDefinition("   border: 5px double #0000FF;");
      CLASS_NODE.add(CLASS_CELL_NODE);
      ROOT_NODE.add(CLASS_NODE);
      final DefaultMutableTreeNode FIELDS_NODE = new DefaultMutableTreeNode("Fields");
      final JavaDocStyleRuleNode FIELD_TABLE_NODE = new JavaDocStyleRuleNode(".fieldTable");
      FIELD_TABLE_NODE.addToStyleRuleDefinition("   border: 1px solid #CC0000;");
      FIELDS_NODE.add(FIELD_TABLE_NODE);
      final JavaDocStyleRuleNode FIELD_HEADING_ROW_NODE = new JavaDocStyleRuleNode(".fieldHeadingRow");
      FIELD_HEADING_ROW_NODE.addToStyleRuleDefinition("   background-color: #660000;");
      FIELD_HEADING_ROW_NODE.addToStyleRuleDefinition("   font-size: 18px;");
      FIELD_HEADING_ROW_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      FIELDS_NODE.add(FIELD_HEADING_ROW_NODE);
      final JavaDocStyleRuleNode FIELD_HEADING_CELL_NODE = new JavaDocStyleRuleNode(".fieldHeadingCell");
      FIELD_HEADING_CELL_NODE.addToStyleRuleDefinition("   border: 3px double #CC0000;");
      FIELDS_NODE.add(FIELD_HEADING_CELL_NODE);
      final JavaDocStyleRuleNode FIELD_ROW_NODE = new JavaDocStyleRuleNode(".fieldRow");
      FIELD_ROW_NODE.addToStyleRuleDefinition("   background-color: #331111;");
      FIELD_ROW_NODE.addToStyleRuleDefinition("   font-size: 16px;");
      FIELD_ROW_NODE.addToStyleRuleDefinition("   font-weight: normal;");
      FIELDS_NODE.add(FIELD_ROW_NODE);
      final JavaDocStyleRuleNode FIELD_ACCESS_CELL_NODE = new JavaDocStyleRuleNode(".fieldAccessCell");
      FIELD_ACCESS_CELL_NODE.addToStyleRuleDefinition("   padding-left: 15px;");
      FIELD_ACCESS_CELL_NODE.addToStyleRuleDefinition("   font-family: 'Courier New', 'Courier', sans-serif;");
      FIELD_ACCESS_CELL_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      FIELDS_NODE.add(FIELD_ACCESS_CELL_NODE);
      final JavaDocStyleRuleNode FIELD_TYPE_CELL_NODE = new JavaDocStyleRuleNode(".fieldTypeCell");
      FIELD_TYPE_CELL_NODE.addToStyleRuleDefinition("   padding-left: 15px;");
      FIELD_TYPE_CELL_NODE.addToStyleRuleDefinition("   color: cyan;");
      FIELDS_NODE.add(FIELD_TYPE_CELL_NODE);
      final JavaDocStyleRuleNode FIELD_NAME_CELL_NODE = new JavaDocStyleRuleNode(".fieldNameCell");
      FIELD_NAME_CELL_NODE.addToStyleRuleDefinition("   padding-left: 15px;");
      FIELDS_NODE.add(FIELD_NAME_CELL_NODE);
      ROOT_NODE.add(FIELDS_NODE);
      final DefaultMutableTreeNode METHODS_NODE = new DefaultMutableTreeNode("Methods");
      final JavaDocStyleRuleNode METHOD_TABLE_NODE = new JavaDocStyleRuleNode(".methodTable");
      METHOD_TABLE_NODE.addToStyleRuleDefinition("   border: 1px solid #00CC00;");
      METHODS_NODE.add(METHOD_TABLE_NODE);
      final JavaDocStyleRuleNode METHOD_HEADING_ROW_NODE = new JavaDocStyleRuleNode(".methodHeadingRow");
      METHOD_HEADING_ROW_NODE.addToStyleRuleDefinition("   background-color: #006600;");
      METHOD_HEADING_ROW_NODE.addToStyleRuleDefinition("   font-size: 18px;");
      METHOD_HEADING_ROW_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      METHODS_NODE.add(METHOD_HEADING_ROW_NODE);
      final JavaDocStyleRuleNode METHOD_HEADING_CELL_NODE = new JavaDocStyleRuleNode(".methodHeadingCell");
      METHOD_HEADING_CELL_NODE.addToStyleRuleDefinition("   border: 3px double #00CC00;");
      METHODS_NODE.add(METHOD_HEADING_CELL_NODE);
      final JavaDocStyleRuleNode METHOD_ROW_NODE = new JavaDocStyleRuleNode(".methodRow");
      METHOD_ROW_NODE.addToStyleRuleDefinition("   background-color: #113311;");
      METHOD_ROW_NODE.addToStyleRuleDefinition("   font-size: 16px;");
      METHOD_ROW_NODE.addToStyleRuleDefinition("   font-weight: normal;");
      METHODS_NODE.add(METHOD_ROW_NODE);
      final JavaDocStyleRuleNode METHOD_ACCESS_CELL_NODE = new JavaDocStyleRuleNode(".methodAccessCell");
      METHOD_ACCESS_CELL_NODE.addToStyleRuleDefinition("   padding-left: 15px;");
      METHOD_ACCESS_CELL_NODE.addToStyleRuleDefinition("   font-family: 'Courier New', 'Courier', sans-serif;");
      METHOD_ACCESS_CELL_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      METHODS_NODE.add(METHOD_ACCESS_CELL_NODE);
      final JavaDocStyleRuleNode METHOD_RETURN_TYPE_CELL_NODE = new JavaDocStyleRuleNode(".methodReturnTypeCell");
      METHOD_RETURN_TYPE_CELL_NODE.addToStyleRuleDefinition("   padding-left: 3px;");
      METHOD_RETURN_TYPE_CELL_NODE.addToStyleRuleDefinition("   padding-right: 15px;");
      METHOD_RETURN_TYPE_CELL_NODE.addToStyleRuleDefinition("   color: cyan;");
      METHODS_NODE.add(METHOD_RETURN_TYPE_CELL_NODE);
      final JavaDocStyleRuleNode METHOD_NAME_CELL_NODE = new JavaDocStyleRuleNode(".methodNameCell");
      METHOD_NAME_CELL_NODE.addToStyleRuleDefinition("   padding-left: 15px;");
      METHODS_NODE.add(METHOD_NAME_CELL_NODE);
      ROOT_NODE.add(METHODS_NODE);
      final DefaultMutableTreeNode CONSTRUCTORS_NODE = new DefaultMutableTreeNode("Constructors");
      final JavaDocStyleRuleNode CONSTRUCTOR_TABLE_NODE = new JavaDocStyleRuleNode(".constructorTable");
      CONSTRUCTOR_TABLE_NODE.addToStyleRuleDefinition("   border: 1px solid #00CCCC;");
      CONSTRUCTORS_NODE.add(CONSTRUCTOR_TABLE_NODE);
      final JavaDocStyleRuleNode CONSTRUCTOR_HEADING_ROW_NODE = new JavaDocStyleRuleNode(".constructorHeadingRow");
      CONSTRUCTOR_HEADING_ROW_NODE.addToStyleRuleDefinition("   background-color: #006666;");
      CONSTRUCTOR_HEADING_ROW_NODE.addToStyleRuleDefinition("   font-size: 18px;");
      CONSTRUCTOR_HEADING_ROW_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      CONSTRUCTORS_NODE.add(CONSTRUCTOR_HEADING_ROW_NODE);
      final JavaDocStyleRuleNode CONSTRUCTOR_HEADING_CELL_NODE = new JavaDocStyleRuleNode(".constructorHeadingCell");
      CONSTRUCTOR_HEADING_CELL_NODE.addToStyleRuleDefinition("   border: 3px double #00CCCC;");
      CONSTRUCTORS_NODE.add(CONSTRUCTOR_HEADING_CELL_NODE);
      final JavaDocStyleRuleNode CONSTRUCTOR_ROW_NODE = new JavaDocStyleRuleNode(".constructorRow");
      CONSTRUCTOR_ROW_NODE.addToStyleRuleDefinition("   background-color: #113333;");
      CONSTRUCTOR_ROW_NODE.addToStyleRuleDefinition("   font-size: 16px;");
      CONSTRUCTOR_ROW_NODE.addToStyleRuleDefinition("   font-weight: normal;");
      CONSTRUCTORS_NODE.add(CONSTRUCTOR_ROW_NODE);
      final JavaDocStyleRuleNode CONSTRUCTOR_ACCESS_CELL_NODE = new JavaDocStyleRuleNode(".constructorAccessCell");
      CONSTRUCTOR_ACCESS_CELL_NODE.addToStyleRuleDefinition("   padding-left: 15px;");
      CONSTRUCTOR_ACCESS_CELL_NODE.addToStyleRuleDefinition("   font-family: 'Courier New', 'Courier', sans-serif;");
      CONSTRUCTOR_ACCESS_CELL_NODE.addToStyleRuleDefinition("   font-weight: bold;");
      CONSTRUCTORS_NODE.add(CONSTRUCTOR_ACCESS_CELL_NODE);
      final JavaDocStyleRuleNode CONSTRUCTOR_NAME_CELL_NODE = new JavaDocStyleRuleNode(".constructorNameCell");
      CONSTRUCTOR_NAME_CELL_NODE.addToStyleRuleDefinition("   padding-left: 15px;");
      CONSTRUCTORS_NODE.add(CONSTRUCTOR_NAME_CELL_NODE);
      ROOT_NODE.add(CONSTRUCTORS_NODE);
      final DefaultMutableTreeNode PARAMETERS_NODE = new DefaultMutableTreeNode("Parameters");
      final JavaDocStyleRuleNode PARAMETER_CELL_NODE = new JavaDocStyleRuleNode(".parameterCell");
      PARAMETER_CELL_NODE.addToStyleRuleDefinition("   padding-left: 15px;");
      PARAMETERS_NODE.add(PARAMETER_CELL_NODE);
      final JavaDocStyleRuleNode PARAMETER_TYPE_NODE = new JavaDocStyleRuleNode(".parameterType");
      PARAMETER_TYPE_NODE.addToStyleRuleDefinition("   color: #A0A0F0;");
      PARAMETERS_NODE.add(PARAMETER_TYPE_NODE);
      final JavaDocStyleRuleNode PARAMETER_NAME_NODE = new JavaDocStyleRuleNode(".parameterName");
      PARAMETER_NAME_NODE.addToStyleRuleDefinition("   color: #A0F0A0;");
      PARAMETERS_NODE.add(PARAMETER_NAME_NODE);
      ROOT_NODE.add(PARAMETERS_NODE);

      // Create the tree.
      final JTree STYLE_TREE = new JTree(ROOT_NODE);
      STYLE_TREE.setShowsRootHandles(true);
      STYLE_TREE.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
      final JScrollPane STYLE_TREE_SCROLL_PANE = new JScrollPane(STYLE_TREE);
      STYLE_TREE_SCROLL_PANE.getVerticalScrollBar().setUnitIncrement(50);
      STYLE_TREE_SCROLL_PANE.getHorizontalScrollBar().setUnitIncrement(25);
      Util.setComponentSizes(STYLE_TREE_SCROLL_PANE, STYLE_TREE_DIM, true, false);
      DIALOG.getContentPane().add(STYLE_TREE_SCROLL_PANE, GRID_CONST);

      GRID_CONST.gridx = 1;
      GRID_CONST.gridy = 4;
      GRID_CONST.gridwidth = 2;
      GRID_CONST.gridheight = 1;
      final JPanel NO_WRAP_PANEL = new JPanel(new BorderLayout());
      NO_WRAP_PANEL.add(Constants.JAVADOC_STYLE_TEXT_PANE);
      final JScrollPane STYLE_SCROLL_PANE = new JScrollPane(NO_WRAP_PANEL);
      STYLE_SCROLL_PANE.getVerticalScrollBar().setUnitIncrement(50);
      STYLE_SCROLL_PANE.getHorizontalScrollBar().setUnitIncrement(25);
      Util.setComponentSizes(STYLE_SCROLL_PANE, STYLE_TEXT_PANE_DIM, true, false);
      DIALOG.getContentPane().add(STYLE_SCROLL_PANE, GRID_CONST);

      STYLE_TREE.addTreeSelectionListener(ActionFactory.createJavaDocStyleTreeSelectionListener(STYLE_TREE));

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 5;
      GRID_CONST.gridwidth = 3;
      GRID_CONST.gridheight = 1;
      GEN_JAVADOC_PANEL.add(BtnFactory.createJavaDocGenBtn(STYLE_TREE));
      DIALOG.getContentPane().add(GEN_JAVADOC_PANEL, GRID_CONST);

      GRID_CONST.gridx = 0;
      GRID_CONST.gridy = 6;
      GRID_CONST.gridwidth = 3;
      GRID_CONST.gridheight = 1;
      CANCEL_PANEL.add(BtnFactory.createJavaDocCloseBtn(DIALOG));
      DIALOG.getContentPane().add(CANCEL_PANEL, GRID_CONST);

      // Pack contents and center on screen.
      DIALOG.pack();
      DIALOG.setLocationRelativeTo(null);
      DIALOG.setAlwaysOnTop(true);

      // Finally, return the dialog.
      return DIALOG;
   } // END createJavaDocGenDialog
} // END class DialogFactory
